<?php
class gCalendarEntry extends dbObject {
	public $google_event_id;
        public $salesforce_event_id;
        public $user_id;

	public function __construct($user_id, $calendar_id, $google_event_id) {
		$this->dbTable = "event:{$user_id}:{$calendar_id}";
		$this->tableKey = 'google_event_id';
		$this->keyType = 'hash';

		if ($google_event_id != null) {
			$entry = $this->find($google_event_id);
			foreach (get_object_vars($entry) as $key => $val) {
				$this->$key = $val;
			}
		}
	}
        
        public function insert() {
		parent::insert();
		
		// ensure this user is in the org set
		if (isset($this->salesforce_event_id)) {
			$sfEntry = new sfCalendarEntry($this->user_id, $this->salesforce_event_id);
                        $sfEntry->google_event_id = $this->google_event_id;
                        $sfEntry->salesforce_event_id = $this->salesforce_event_id;
			$sfEntry->insert();
		}
	}
}
?>